package com.zhh.springcloud.feignService;

import com.zhh.springcloud.model.Department;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

// feign通过调用服务提供者controller实现的service层，到时候用这个去实现消费者的controller层
// feign实现方法：注册主机名+url
@Component
@FeignClient(value = "springcloud-provider")
public interface FeignService {

    @PostMapping("/provider/add")
    public int add(@RequestBody Department department);

    @GetMapping("/provider/delete")
    public int delete(@RequestParam(value = "id", required = false) int id);

    @PostMapping("/provider/modify")
    public int modify(@RequestBody Department department);

    @GetMapping("/provider/get")
    public Department getById(@RequestParam(value = "id", required = false) int id);

    @GetMapping("/provider/getall")
    public List<Department> getAll();

}
